/**
 * 添加产品类型
 */
layui.use(['layer', 'form', 'admin', 'ax', 'inputTags'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var layer = layui.layer;
    var inputTags = layui.inputTags;
    console.log("tags对象："+inputTags);
    var labelStr = "";
    inputTags.render({
        elem: '#label', //定义输入框input对象
        content: [], //默认标签
        aldaBtn: false, //是否开启获取所有数据的按钮
        done: function(value) { //回车后的回调
            labelStr += value+","
            console.log("刚刚输入标签===="+value);
        }
    });



    // 表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        data.field.label = labelStr;
        var ajax = new $ax(Feng.ctxPath + "/productType/add", function (data) {
            Feng.success("添加成功！");

            //传给上个页面，刷新table用
            admin.putTempData('formOk', true);

            //关掉对话框
            admin.closeThisDialog();

        }, function (data) {
            Feng.error("添加失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        //添加 return false 可成功跳转页面
        return false;
    });
});